<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ChBT8H8zUjG9dFc7eTVbjDjrvYNjOIPd">
</script>

<body>
<label>输入关键字</label>&nbsp;<input size="12" id="keyword" name="keyword" type="text"/><button onclick="exportExcel()">查找</button>

<script>

var resArray = new Array(),j=1,tt=1,querykey ="";
function _exportExcel(resArray){
	$("#exportExcelForm").remove();
	var formHtml = '<form name="exportExcelForm" id="exportExcelForm">';
	formHtml += '<input type="hidden" name="keyword" value="' + querykey + '">';
	formHtml += '<input type="hidden" name="data" value="">';
	formHtml += '</form>';
	$('body').append(formHtml);
	$("[name='data']").val(JSON.stringify(resArray));
	
	document.exportExcelForm.action = "/hello/getPageData?time="+new Date().getTime();
	document.exportExcelForm.target = '_top';
	document.exportExcelForm.method = 'post';
	document.exportExcelForm.submit();
	
}
var local = new BMap.LocalSearch("赤峰", {
	    pageCapacity:50,
		onSearchComplete:function(rs){
			if(typeof(rs) == "undefined"){
				console.log("--------------查询已结束------------------------")
				if(resArray.length !=0){
					_exportExcel(resArray);
				}
				return false;
			}
			for(var i=0;i<rs.getCurrentNumPois();i++){
				var poi = rs.getPoi(i);
				var rsObj = {
					id:tt,
					x:poi.point.lng,
					y:poi.point.lat,
					key:poi.title
				}
				tt++;
				resArray.push(rsObj);
			}
			
			if(rs.getPageIndex()!=rs.getNumPages()){
				local.gotoPage(j);
				j=j+1;
			}
		}
});
function exportExcel(){
	resArray = new Array();
	j=1;
	tt=1;
	querykey = $("#keyword").val();
	console.log("--------------查询已开始-------关键字为：'"+querykey+"'-----------")
	local.search("红山区"+querykey);
}
//

</script>
</body>